//
//  CSSearchResultModel.swift
//  Cycling
//
//  Created by CSS on 4/1/23.
//

import Foundation

struct CSSearchResultModel: Codable {
    
    var name: String?
    var type: ResultType = .popular
    
}

// MARK: 枚举类型
extension CSSearchResultModel {
    
    enum ResultType: Int, Codable {
        case popular, hot, personal
        
        var typeString: String {
            switch self {
            case .popular:
                return "常去路线"
            case .hot:
                return "热门路线"
            case .personal:
                return "私人路线"
            }
        }
        
        var typeColor: UIColor {
            switch self {
            case .popular:
                return .color(withHexString: "#36BAFF")
            case .hot:
                return .color(withHexString: "#FA2C1E")
            case .personal:
                return .color(withHexString: "#0AD39F")
            }
        }
        
        var typeIconImage: UIImage? {
            switch self {
            case .popular:
                return .init(named: "map_route_popular")
            case .hot:
                return .init(named: "map_route_hot")
            case .personal:
                return .init(named: "map_route_personal")
            }
        }
    }
    
}

// MARK: 测试数据
extension CSSearchResultModel {
    
    static func testDatas() -> [CSSearchResultModel] {
        
        [("深圳出版产业园", ResultType.popular), ("深圳财经技术学院", ResultType.hot), ("深圳人民公园", ResultType.personal)].reduce([], {
            $0 + [.init(name: $1.0, type: $1.1)]
        })
        
    }
    
}
